workaround github cache output issues. (#749)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Sat, 30 Oct 2021 14:14:11 +0000 (08:14 -0600)
committerGitHub <noreply@github.com>
Sat, 30 Oct 2021 14:14:11 +0000 (08:14 -0600)
a cache hit is reported only for an exact match.  But in a pull
request we can have an inexact match result in cache being fetched.

.github/workflows/windows.yml
tools/ci_install_windows.sh

index 0299a6ee1710852d998164c1b6c941ff86c9e5ad..1f507a8ebf4737564d838694f1658ebbc8f5af39 100644 (file)
@@ -53,7 +53,7 @@ jobs:
             ARCH: 'amd64'
             HOST_ARCH: 'amd64'
             COMPILER: 'msvc2019_64'
-            AQTARCH: 'win64_msvc2019_64'
+            METHOD: 'aqt'
             RELEASE: false
             FLOW: 'nmake'
 
@@ -69,25 +69,18 @@ jobs:
         key: ${{ runner.os }}-${{ matrix.QT_VERSION }}-${{ matrix.COMPILER }}-${{ secrets.CACHE_VERSION }}
 
     - name: Install Qt setup(aqt)
-      if: ${{ (steps.cache.outputs.cache-hit != 'true') && startsWith(matrix.QT_VERSION, '6') }}
+      if: steps.cache.outputs.cache-hit != 'true'
       uses: actions/setup-python@v2
       with:
         python-version: '3.9'
 
-    - name: Install Qt(aqt)
-      if: ${{ (steps.cache.outputs.cache-hit != 'true') && startsWith(matrix.QT_VERSION, '6') }}
-      shell: bash
-      run: |
-        pip3 install aqtinstall>=2.0.0
-        ./tools/ci_install_qt.sh windows ${{ matrix.QT_VERSION }} ${{ matrix.AQTARCH }} ${HOME}/Cache/Qt
-
     - name: Install Qt
-      if: ${{ (steps.cache.outputs.cache-hit != 'true') && !startsWith(matrix.QT_VERSION, '6') }}
+      if: steps.cache.outputs.cache-hit != 'true'
       env:
         CI_BUILD_DIR: ${{ github.workspace }}
       shell: bash
       run: |
-        ./tools/ci_install_windows.sh ${{ matrix.QT_VERSION }} ${{ matrix.COMPILER }}
+        ./tools/ci_install_windows.sh ${{ matrix.QT_VERSION }} ${{ matrix.COMPILER }} ${{ matrix.METHOD }}
 
     - name: Build
       shell: powershell
index 0a3c1655ade5b6097a5524f7bd1093ca10a44223..a14c99185dd3784381afa0183e208132549dc87c 100755 (executable)
@@ -20,10 +20,14 @@ function validate() {
 
 QT_VERSION=${1:-5.12.10}
 COMPILER=${2:-msvc2017_64}
+METHOD=${3:-default}
+
 if [ "${COMPILER}" = "msvc2017_64" ]; then
   PACKAGE_SUFFIX=win64_msvc2017_64
 elif [ "${COMPILER}" = "msvc2017" ]; then
   PACKAGE_SUFFIX=win32_msvc2017
+elif [ "${COMPILER}" = "msvc2019_64" ]; then
+  PACKAGE_SUFFIX=win64_msvc2019_64
 else
   echo "ERROR: unrecognized Qt compiler ${COMPILER}." >&2
   exit 1
@@ -36,18 +40,27 @@ if [ -d "${QTDIR}/bin" ]; then
   echo "Using cached Qt."
 else
   rm -fr "${CACHEDIR}"
-  QT_VERSION_SHORT=${QT_VERSION//./}
-  curl -s -L -o "qt-opensource-windows-x86-${QT_VERSION}.exe" "https://download.qt.io/official_releases/qt/5.12/${QT_VERSION}/qt-opensource-windows-x86-${QT_VERSION}.exe"
-  ls -l ./*.exe
-  netsh advfirewall firewall add rule name=dummyupqt dir=out action=block program="$(cygpath -w "${PWD}/qt-opensource-windows-x86-${QT_VERSION}.exe")"
-  "${PWD}/qt-opensource-windows-x86-${QT_VERSION}.exe" --verbose --script "${CI_BUILD_DIR}/tools/qtci/qt-install.qs" QTCI_OUTPUT="${CACHEDIR}/Qt" QTCI_PACKAGES="qt.qt5.${QT_VERSION_SHORT}.${PACKAGE_SUFFIX},qt.qt5.${QT_VERSION_SHORT}.qtwebengine"
-  netsh advfirewall firewall delete rule name=dummyupqt
-  rm "qt-opensource-windows-x86-${QT_VERSION}.exe"
-  ls "${CACHEDIR}/Qt"
-  rm -fr "${CACHEDIR}/Qt/Docs"
-  rm -fr "${CACHEDIR}/Qt/Examples"
-  rm -fr "${CACHEDIR}/Qt/Tools"
-  rm -f "${CACHEDIR}/Qt/MaintenanceTool.*"
-  echo "export PATH=${QTDIR}/bin:\$PATH" > "${CACHEDIR}/qt.env"
+  mkdir -p "${CACHEDIR}"
+
+  if [ "${METHOD}" = "aqt" ]; then
+    pip3 install aqtinstall>=2.0.0
+    "${CI_BUILD_DIR}/tools/ci_install_qt.sh" windows "${QT_VERSION}" "${PACKAGE_SUFFIX}" "${CACHEDIR}/Qt"
+    echo "export PATH=${QTDIR}/bin:\$PATH" > "${CACHEDIR}/qt.env"
+  else
+    QT_VERSION_SHORT=${QT_VERSION//./}
+    QT_VERSION_MAJMIN=${QT_VERSION%.*}
+    curl -s -L -o "qt-opensource-windows-x86-${QT_VERSION}.exe" "https://download.qt.io/official_releases/qt/${QT_VERSION_MAJMIN}/${QT_VERSION}/qt-opensource-windows-x86-${QT_VERSION}.exe"
+    ls -l ./*.exe
+    netsh advfirewall firewall add rule name=dummyupqt dir=out action=block program="$(cygpath -w "${PWD}/qt-opensource-windows-x86-${QT_VERSION}.exe")"
+    "${PWD}/qt-opensource-windows-x86-${QT_VERSION}.exe" --verbose --script "${CI_BUILD_DIR}/tools/qtci/qt-install.qs" QTCI_OUTPUT="${CACHEDIR}/Qt" QTCI_PACKAGES="qt.qt5.${QT_VERSION_SHORT}.${PACKAGE_SUFFIX},qt.qt5.${QT_VERSION_SHORT}.qtwebengine"
+    netsh advfirewall firewall delete rule name=dummyupqt
+    rm "qt-opensource-windows-x86-${QT_VERSION}.exe"
+    ls "${CACHEDIR}/Qt"
+    rm -fr "${CACHEDIR}/Qt/Docs"
+    rm -fr "${CACHEDIR}/Qt/Examples"
+    rm -fr "${CACHEDIR}/Qt/Tools"
+    rm -f "${CACHEDIR}/Qt/MaintenanceTool.*"
+    echo "export PATH=${QTDIR}/bin:\$PATH" > "${CACHEDIR}/qt.env"
+  fi
 fi
 validate